package com.smartservice.ui;

import android.R.integer;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.text.style.LineHeightSpan;
import android.util.AttributeSet;
import android.widget.EditText;
import android.widget.Space;

public class CustomEditText extends EditText {
	private Paint lineStyle = new Paint();

	public CustomEditText(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		initLineStyle();
	}

	public CustomEditText(Context context, AttributeSet attrs) {
		super(context, attrs);
		initLineStyle();
	}

	public CustomEditText(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		initLineStyle();
	}

	private void initLineStyle() {
		lineStyle.setStyle(Paint.Style.STROKE);
		lineStyle.setColor(0xff888888);
	}

	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		int left = getLeft();
		int right = getRight();
		int paddingTop = getPaddingTop();
		int paddingBottom = getPaddingBottom();
		int paddingLeft = getPaddingLeft();
		int paddingRight = getPaddingRight();
		int height = getHeight();
		int lineHeight = getLineHeight();
		int count = (height - paddingTop - paddingBottom) / lineHeight;
		for (int i = 0; i < count; i++) {
			int baseline = lineHeight * (i + 1) + paddingTop;
			canvas.drawLine(left + paddingLeft, baseline, right - paddingRight,
					baseline, lineStyle);
		}
		super.onDraw(canvas);
	}

}
